package com.briup.app02.web.controller;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app02.bean.Category;
import com.briup.app02.service.ICategoryService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/category")
@Api(description="栏目管理")
public class CategoryController {
	
	@Autowired
	private ICategoryService categoryService;
	
	@GetMapping("findAll")
	@ApiOperation("查询所有栏目信息")
	public List<Category> findAll(){
		return categoryService.findAll();
	}
	
	@GetMapping("findById")
	@ApiOperation("根据id查询栏目信息")
	@ApiImplicitParam(name="id",value="栏目id",dataType="long",paramType="query")
	public Category findById(long id) {
		return categoryService.findById(id);
	}
	
	@GetMapping("saveOrUpdate")
	@ApiOperation(value="保存或更新",notes="id为空是保存否则是更新")
	public String saveOrUpdate(Category category) {
		categoryService.saveOrUpdate(category);
		return "操作成功";
	}
	@GetMapping("deleteById")
	@ApiOperation("根据id删除栏目信息")
	@ApiImplicitParam(name="id",value="栏目id",dataType="long",paramType="query",required=true)
	public String deleteById(long id) {
		categoryService.deleteById(id);
		return "删除成功";
	}
}







